<!DOCTYPE html>
<html>
<head>
<title>postVideo</title>
<style type="text/css">
input[type="text"] {
	width: 100%;
	box-sizing: border-box;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="jquery-1.8.3.min.js"></script>
<script type="text/javascript">
<!--
	function postVideo() {
		var json = JSON.stringify({
			key: $("#key").val(),
			title: $("#title").val(),
			desc: $("#desc").val(),
			date: $("#date").val(),
			duration: parseInt($("#duration").val()),
			expired: $("#expired").val(),
			size: parseInt($("#size").val())
		});
		$("#json").text(json);

		$("body").css("cursor", "progress");
		$("#post").attr("disabled", "disabled");
		$.ajax({
			url: "/rest/videos",
			type: "POST",
			dataType: "json",
			contentType: "application/json; charset=utf-8",
			data: json,
			success: function(data, textStatus, jqXHR) {
				$("body").css("cursor", "auto");
				alert("success");
				$("#post").attr("disabled", null);
			},
			error: function(jqXHR, textStatus, errorThrown) {
				$("body").css("cursor", "auto");
				alert("fail: " + errorThrown);
				$("#post").attr("disabled", null);
			}
		});
	}
//-->
</script>
</head>
<body>
	<h1>postVideo</h1>
	<p>/rest/videosに対して、JSON形式でPOSTするためのデバッグ用フォーム</p>
	<table border="1">
		<tr>
			<th>Key</th>
			<td><input id="key" type="text" /></td>
		</tr>
		<tr>
			<th>Title</th>
			<td><input id="title" type="text" /></td>
		</tr>
		<tr>
			<th>Description</th>
			<td><textarea id="desc" cols="40" rows="10"></textarea></td>
		</tr>
		<tr>
			<th>Date</th>
			<td><input id="date" type="text" value="2012-11-28T0:38:43.005+0900" /></td>
		</tr>
		<tr>
			<th>Duration (ms)</th>
			<td><input id="duration" type="text" value="0" /></td>
		</tr>
		<tr>
			<th>Size (bytes)</th>
			<td><input id="size" type="text" value="0" /></td>
		</tr>
		<tr>
			<th>Expired</th>
			<td><input id="expired" type="text" value="2012-12-31T23:59:59.999+0900" /></td>
		</tr>
	</table>
	<br/>
	<button id="post" type="button" onclick="postVideo()">POST</button>
	<p><div id="json"></div></p>
</body>
</html>
